
#include <QString>
#include <unordered_map>

enum class ErrorCode {
    NoError,
    Unknown,
    UserExist,
    UserLogined,
    UnknowUser,
    ErrorPassword,
};

inline QString GetErrorMessage(ErrorCode code) {
    static const std::unordered_map<ErrorCode, QString> errorMessages = {
        {ErrorCode::NoError, "没有错误"},
        {ErrorCode::Unknown, "未知错误"},
        {ErrorCode::UserExist, "用户已存在"},
        {ErrorCode::UserLogined, "用户已登录"},
        {ErrorCode::UnknowUser, "用户不存在"},
        {ErrorCode::ErrorPassword, "密码错误"},
    };

    auto it = errorMessages.find(code);
    if (it != errorMessages.end()) {
        return it->second;
    }
    return "未知错误";
}
